#pragma GCC optimize(2)
#include <iostream>
#include <queue>
#include <map>
#include <unordered_map>
#include <vector>
#include <algorithm>
#include <cmath>
#include <string>
#include <cstring>
#include <set>
#include <unordered_set>
#define IOS ios::sync_with_stdio(false), cin.tie(0), cout.tie(0)
using namespace std;
typedef __int128 ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
const ll mod=1e10;
ll a[1010];
ll qpow(ll a,ll n)
{
    ll res=1;
    while(n)
    {
        if((n&1)==1)
        {
            res=1LL*res*a%mod;
        }
        a=1LL*a*a%mod;
        n>>=1;
    }
    return res;
}
int main()
{
    for(ll i=1;i<=1000;i++)
    {
        a[i]=(1LL*qpow(i,i)+a[i-1])%mod;
    }
    int t;
    cin>>t;
    while(t--)
    {
        int n;cin>>n;
        cout<<(long long)a[n]<<endl;
    }

    return 0;
}
